<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
	#div1 {width: 100px; height: 100px; background: red; position: absolute;}	
</style>
<script>
	window.onload = function()
	{
			document.onkeydown= function(ev)
			{
					var oEvent = ev||event;
					var oDiv = document.getElementById('div1');
					//alert(oEvent.keyCode);
			
					if(oEvent.keyCode==37)
						{
								oDiv.style.left=oDiv.offsetLeft -10 + 'px';
						}else if(oEvent.keyCode==39)
						{
							oDiv.style.left=oDiv.offsetLeft + 10 + 'px';
						}else if(oEvent.keyCode==40)
						{
								oDiv.style.top=oDiv.offsetTop + 10 + 'px';
						}else if(oEvent.keyCode==38)
						{
								oDiv.style.top=oDiv.offsetTop - 10 + 'px';
						}

			};
	}
	</script>
</head>

<body>
<div id="div1">
	
</div>
</body>
</html>
